package com.itheima.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.common.vo.PageResultVo;
import com.itheima.user.dto.ApUserRealnamePageRequestDto;
import com.itheima.user.mapper.ApUserRealnameMapper;
import com.itheima.user.pojo.ApUserRealname;
import com.itheima.user.service.ApUserRealnameService;
import org.springframework.stereotype.Service;

/**
 * @version 1.0
 * @description <p>APP实名认证信息 业务实现</p>
 * @package com.itheima.user.service.impl
 */
@Service
public class ApUserRealnameServiceImpl extends ServiceImpl<ApUserRealnameMapper, ApUserRealname> implements ApUserRealnameService {

    @Override
    public PageResultVo<ApUserRealname> findByPage(ApUserRealnamePageRequestDto dto) {
        //1 设置分页参数
        IPage<ApUserRealname> page = new Page<>();
        page.setSize(dto.getSize());
        page.setPages(dto.getPage());
        //2 追加条件
        LambdaQueryWrapper<ApUserRealname> lqw = new LambdaQueryWrapper<>();
        lqw.eq(null != dto.getStatus(), ApUserRealname::getStatus, dto.getStatus());
        //3 查询
        page(page,lqw);
        //4 构造返回
        return PageResultVo.pageResult(dto.getPage(),dto.getSize(),page.getTotal(),page.getRecords());
    }
}
